﻿

@model PagedList<JiesuanMasterModel>
@{
    ViewBag.Title = "结算单列表";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    JiesuanQueryModel paramModel = new JiesuanQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (JiesuanQueryModel)ViewBag.paramModel;
    }
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();

}
<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("JiesuanList", "Jiesuan")" method="get">
    <div class="form_query">
        <div>
            供应商：
            <input type="text" name="supplier_name" id="supplier_name" class="abc input-default" placeholder="" value="@paramModel.supplier_name">&nbsp;
        </div>
        <div>
            结算状态：
            <select id="jiesuan_master_status" name="jiesuan_master_status">
                <option value="-10" @(paramModel.jiesuan_master_status == -10 ? "selected" : "")>全部</option>
                @{
                    dc = new Dictionary<string, string>();
                    MyEnumHelper.GetEnumItems(typeof(jiesuan_master_status)).ForEach(t =>
                    {
                        dc.Add(t.Value.ToString(), t.Description);
                    });
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.jiesuan_master_status.ToString());
            </select>&nbsp;
        </div>
        <div>
            @{Html.RenderPartial(Url.Content("~/Views/Common/PageSize.cshtml"), paramModel);}
        </div>
        <div>
            <button type="submit" class="btn btn-primary" id="formsubmit">查询</button>
        </div>
    </div>
    <table class="table table-bordered table-hover definewidth m10">
        <thead>
            <tr>
                <th>结算类型</th>
                <th>收款方名称</th>
                <th>结算金额</th>
                <th>实际结算金额</th>
                <th>结算概况(订单号|支付类型|订单金额|供货金额|货币类型)</th>
                <th>结算状态</th>
                <th>结算单生成时间</th>
                <th>审核申请提交时间</th>
                <th>操作</th>
            </tr>
        </thead>
        @if (Model != null && Model.Count != 0)
        {
            int index = 0;
            foreach (var m in Model)
            {
                index++;
                <tr class="@HtmlPagerHelper.TrClass(index)">
                    <td> 货款（向供应商付款） </td>
                    <td>@m.aDZ_JiesuanMaster.supplier_name</td>
                    <td>@m.aDZ_JiesuanMaster.jiesuan_money</td>
                    <td>@m.aDZ_JiesuanMaster.jiesuan_money_real</td>
                    <td>
                        @if (m.jiesuanOrderDetails != null)
                        {
                            foreach(var t in m.jiesuanOrderDetails)                           
                            {
                                <info><a href="@Url.Action("OrderMasterInfo","OrderMaster",new { id=t.order_id })">@t.order_no</a>|货款|@t.order_money|@t.supply_money|@(MyEnumHelper.GetEnumItemDescription<CurrencyType>(t.currency_type))<br /></info>
                            }
                        }

                    </td>
                    <td>
                        @(MyEnumHelper.GetEnumItemDescription<jiesuan_master_status>(m.aDZ_JiesuanMaster.jiesuan_status))
                    </td>
                    <td> @m.aDZ_JiesuanMaster.create_time.ToString(1)</td>
                    <td> @m.aDZ_JiesuanMaster.last_time.ToString(1)</td>
                    <td>
                        @if (m.aDZ_JiesuanMaster.jiesuan_status == (int)jiesuan_master_status.Created)
                        {
                            <a href="@Url.Action("caiwujiesuanauding","jiesuan",new { jiesuan_id=m.aDZ_JiesuanMaster.jiesuan_id})">财务审核</a>
                        }
                        else if (m.aDZ_JiesuanMaster.jiesuan_status == (int)jiesuan_master_status.CaiwuPassed)
                        {
                            <a href="@Url.Action("managerjiesuanauding","jiesuan",new { jiesuan_id=m.aDZ_JiesuanMaster.jiesuan_id})">总经理审核</a>
                        }
                        else if (m.aDZ_JiesuanMaster.jiesuan_status == (int)jiesuan_master_status.ManagerPass)
                        {
                            <a href="@Url.Action("chunapay","jiesuan",new { jiesuan_id=m.aDZ_JiesuanMaster.jiesuan_id})">出纳付款</a>
                        }
                        &nbsp;
                            <a href="@Url.Action("detailinfo","jiesuan",new { jiesuan_id=m.aDZ_JiesuanMaster.jiesuan_id})">查看详情</a>
                        
                    </td>
                </tr>
            }
            <tr>
                <td colspan="20"></td>
            </tr>
        }
    </table>
    <div class="inline pull-left total">
        总行数：@ViewData["AllCount"] | 总订单金额：@string.Format("{0:N2}", ViewData["order_money"])
    </div>
    <div class="inline pull-right page">
        @if (Model != null)
        {
            @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
        }
    </div>
</form>
<script>
    var cancelButton =
        {
            text: '取消',
            elCls: 'button',
            handler: function () {
                this.close();
            }
        };
    reloadHandler = function () {
        window.location.reload();
    }

    $("#dojiesuan").click(function () {
        var ids = getCheckboxList();
        if (ids.length == 0) {
            BUI.Message.Alert("请选择要结算的数据", 'warning');
            return;
        }
        $("#Jiesuan_Form").ajaxSubmit(function (result) {
            ShowActionResult(result, function () { self.location = document.referrer; });//self.location = document.referrer;
        });
    });
</script>
